FROM ubuntu:23.10 AS builder
RUN apt-get update && apt-get install -y wget tar
RUN wget -O /openjdk-21_linux-x64_bin.tar.gz https://download.oracle.com/java/21/latest/jdk-21_linux-x64_bin.tar.gz
# 解压OpenJDK
RUN mkdir -p /jdk && tar -xzvf /openjdk-21_linux-x64_bin.tar.gz -C /jdk
# 安装OpenJDK
FROM ubuntu:23.10
COPY --from=builder /jdk /var/opt/
#配置环境变量
ENV JAVA_HOME /var/opt/jdk-21.0.4
ENV CLASSPATH :$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
ENV PATH $PATH:$JAVA_HOME/bin
 # 作者
LABEL u="何桥"
RUN chmod +x $JAVA_HOME/bin/* && mkdir -p /app

# 指定容器监听的端口
EXPOSE 81
# 启动脚本
ENTRYPOINT ["java", "-jar"]
